package cn.ymkj.controller;

import cn.ymkj.pojo.User;
import cn.ymkj.service.UserService;
import cn.ymkj.vo.R;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "用户相关请求的接口")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/findAll")
    public R findAll(){
        List<User> users = userService.findAll();
        return R.ok("获取所有用户成功",users);
    }

    @GetMapping("/deleteById")
    public R deleteById(Integer userId){
        int row = userService.deleteById(userId);
        return R.ok("删除成功");
    }
}
